import { Component, OnInit } from '@angular/core';
import { CommonService } from '../../service/common.service'
import { EventService } from '../../service/event.service'

@Component({
  selector: 'app-havestore',
  templateUrl: './havestore.page.html',
  styleUrls: ['./havestore.page.scss'],
})
export class HavestorePage implements OnInit {
  public buyList:any[]=[];
  
  constructor(private common:CommonService,private eventService:EventService) {
  }

  ngOnInit() {
    this.getUserBuy()

    //监听 信息缓存 事件
    this.eventService.event.on('useractive',()=>{
      console.log('更新激活')
      this.getUserBuy()
    })
  }

  // 购买列表
  getUserBuy(){
    var api = '/tbr/getUserBuyList'
    var params = {
      userId:this.common.getInfo().userId,
      page:1,
      limit:100
    }
    this.common.post(api,params,false).then((res:any)=>{
      console.log(res)
      if(res.code == 200){
        // this.getcreate()
        this.buyList = res.data.records   
      }
    })
  }

}
